<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2010 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Bifrost Theme for PHP-Fusion
| Filename: theme.php
| Author: Johan Wilson
| Version 1.1
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/

if (!defined("IN_FUSION")) { die("Access Denied"); }

if (file_exists(THEME."locale/".LOCALESET."locale.php")) {
	require_once THEME."locale/".LOCALESET."locale.php";
} else {
	require_once THEME."locale/English/locale.php";
}
require_once INCLUDES."theme_functions_include.php";
require_once THEME."config.php";
require_once THEME."header.php";
require_once THEME."functions.php";
require_once THEME."footer.php";

function render_page() {
	global $aidlink, $locale, $settings, $userdata; add_handler("theme_head_output"); ?>
<div id="content" class="container_24">
	<div id="header">
		<div id="logo" class="grid_6">
		<?php echo showbanners(); ?>
		</div><!-- /logo -->
		<div id="nav" class="grid_16 push_1">
			<?php navigation(); ?>
		</div><!-- /nav -->
		<div class="grid_9 hinfo">
			<h4>Example Content</h4>
			<p>Lorem ipsum dolor sit amet.</p>
		</div><!-- /hinfo -->
		<div class="grid_6 push_1 hinfo">
			<h4><?php echo $locale['Search_box_title']; ?></h4>
			<form action="/search.php" id="search" method="get" role="search" />
				<div>
					<label for="s" class="screen-reader-text"><?php echo $locale['Search_label']; ?></label>
					<input type="text" id="s" name="stext" value="" />
					<input type="submit" value="<?php echo $locale['Search_value']; ?>" id="searchsubmit" />
				</div>
			</form>
		</div><!-- /search -->
		<div class="grid_6 push_2 userinfo hinfo">
			<?php userinfo(); ?>
		</div><!-- /userinfo --> 
	</div><!-- /header -->
	<div id="main" class="grid_24">
		<?php echo U_CENTER; ?>
		<?php echo CONTENT; ?>
		<?php echo L_CENTER; ?>
	</div><!-- /main --> 
</div><!-- /content -->
<div id="footer">
	<div class="container_24">
		<?php navigation(false); ?>
		<div class="clearfix"></div>
		<div id="subfooter">
			<small><?php echo showcopyright(); ?></small>
		</div><!-- /subfooter --> 
	</div>
</div><!-- /footer -->
<?php get_footer_tags(); ?>
<?php echo (DEBUG ? "<div id='debug'><strong>Debug is on </strong>" : "<!-- ").showrendertime().(DEBUG ? "</div><!-- /debug -->": " -->")."\n";
}

function render_news($subject, $news, $info) {
	global $locale,$data,$settings; 
		echo !isset($_GET['readmore']) && $info['news_ext'] == "y" ? "<h2 class='posttitle'><a href='/news.php?readmore=".$info['news_id']."'>".strip_tags($subject)."</a></h2>\n" : opentable($subject); ?>
<div class="postmeta">
	<span><?php echo showdate("%B %d, %Y", $info['news_date']); ?></span>
	<span class="i-cat"><?php echo $locale['news_in']; ?> <?php echo substr(newscat($info), 18); ?></span>
	<span class="i-aur"><?php echo $locale['news_by']; ?> <?php echo profile_link($info['user_id'], $info['user_name'], $info['user_status']); ?></span>
	<span class="i-com"> <?php echo $info['news_allow_comments'] && $settings['comments_enabled'] == "1" ? "<a href='news.php?readmore=".$info['news_id']."#comments'>".($info['news_comments'] != 0 ? $info['news_comments'] : "").($info['news_comments'] == 1 || $info['news_comments'] == 0  ? $locale['global_073b'] : $locale['global_073'])."</a>": ""; ?></span>
</div>
<div class="post">
	<?php echo "$news\n"; ?>
</div>
<?php	closetable();
}

function render_article($subject, $article, $info) {
	global $locale;	
	opentable($subject);
	echo "<div class='postmeta'>".($info['article_breaks'] == "y" ? nl2br($article) : $article)."</div>
	<div>
		".articleposter($info," &middot;").articleopts($info,"&middot;").itemoptions("A",$info['article_id']).
	"</div>\n";
	closetable();
}

$pi=0;
function opentable($title="") {
	static $pi;
	echo (!empty($title) ? ($pi==0 ? "<h1 class='title'>$title</h1>" : "<h2 class='title'>$title</h2>") : "")."\n";
	$pi++;
}

function closetable() {
	echo "\t\t<!-- /section -->\n";
}

function openside($title="", $collapse = false, $state = "on") {
	echo !empty($title) ? "<h3>$title</h3>\n" : "";
}

function closeside() {
	echo "<!-- /side -->";
}